# config/gunicorn_config.py

import multiprocessing

# 基础配置
bind = "127.0.0.1:8080"
#workers = 4  # 推荐值：CPU核心数 × 2 + 1
#bind = "unix:/tmp/gunicorn.sock"  # 使用Unix Socket提升性能
workers = multiprocessing.cpu_count() * 2 + 1
timeout = 600
threads = 8
keepalive = 5

# 高级配置
worker_class = "gevent"  # 使用异步worker提升性能
max_requests = 1000      # 防止内存泄漏
max_requests_jitter = 50

# 安全配置
limit_request_line = 8192  # 最大请求头大小
# proxy_protocol = True      # 启用代理协议支持

# 日志配置
accesslog = "logs/access.log"
errorlog = "logs/error.log"
capture_output = True
loglevel = "info"
preload_app = True  # 预加载应用减少内存占用


# 应用配置
chdir = "/app/afa/afa5/afa4j/pdfutil/pdfserver"  # 项目根目录
